﻿/* for grid */
/*var curRg = null;*/
/*var curTCID = null; define in code*/
var curMainObj = null;
var curObj = null;
/*var divShowCID = null; define in code*/
var curDataDivShow = null;
var curDataDivShowIndex = null;
var curDataGridShow = null;
var stopFocus = null;


function buildSide(div, result)
{
    var str1 = "<div class='sideItem' > <a id='A11'  href='Default.aspx?_p=1'  >Hồ sơ mới (<label style='color:red;'>"+result[0]+"</label>)</a> </div>";
    var str2 = "<div class='sideItem' > <a id='A21'  href='Default.aspx?_p=2' >Hồ sơ đã chuyển (<label style='color:green;'>"+result[1]+"</label>)</a> </div>";
    var str3 = "<div class='sideItem' > <a id='A31'  href='Default.aspx?_p=3'>Hồ sơ đã xử lý (<label style='color:blue;'>"+result[2]+"</label>)</a> </div>";
    var str4 = "<div class='sideItem' > <a id='A41'  href='Default.aspx?_p=4'>Hồ sơ đang xử lý ("+result[3]+")</a> </div>";
    var str5 = "<div class='sideItem' > <a id='A51'  href='Default.aspx?_p=5' >Hồ sơ trể ("+result[4]+")</a> </div>";
    var str6 = "<div class='sideItem' > <a id='A61'  href='Default.aspx?_p=6'>Hồ sơ lỗi ("+result[5]+")</a> </div>";
    var str6 = "<div class='sideItem' > <a id='A61'  href='Default.aspx'  >Trang chủ </a> </div>";
    div.innerHTML = str1+str2+str3+str4+str5+str6;
}
function getTD(val, style)
{
    var space = "&nbsp;";
    if(val!=null)
        space = val;
    return "<td "+style+">"+space+ "</td>";
}


function onProcessClick(e)
{
var x = 0;
	var y = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		x = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		y = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

var divBounds=Sys.UI.DomElement.getBounds($get(divShowCID));
var divShow = $get(divShowCID);


if(divShow && divBounds)
{
    if (  ((divBounds.x < x )&& (x < divBounds.x + divBounds.width))
           && ((divBounds.y < y )&& (y < divBounds.y + divBounds.height))  )
    {
        divShow.style.display = "block";
    }
    else
    {
        
        divShow.style.display = "none";
    }
}

}

function getChild(args, str)
{
if(args.get_item().get_cell(str) == null)
    return null;
    var obj = args.get_item().get_cell(str).childNodes[0];
   if(obj==null)
        obj = args.get_item().get_cell(str).childNodes[1];
   else
   {
       if(obj.id=='undefined')
            obj = args.get_item().get_cell(str).childNodes[1];
       if(obj.id==null)
            obj = args.get_item().get_cell(str).childNodes[1];
   }
   return obj;
}


function getDataItemKeyValue(radGrid, item)
{
    return parseInt(radGrid.get_masterTableView().getCellByColumnUniqueName(item,"Id").innerHTML);
}

function getInternetExplorerVersion() 
{    var rv = -1; 

// Return value assumes failure.   
 if (navigator.appName == 'Microsoft Internet Explorer') 
 {        var ua = navigator.userAgent;        
 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");        
 if (re.exec(ua) != null)            rv = parseFloat(RegExp.$1);   
  }    
 return rv;
 }
 function checkVersion() {   
  var msg = "You're not using Windows Internet Explorer.";    
  var ver = getInternetExplorerVersion();    
  if (ver > -1) 
  {        if (ver >= 8.0)           
                 msg = "You're using a recent copy of Windows Internet Explorer." ;
   else           
         msg = "You should upgrade your copy of Windows Internet Explorer.";    
         }    
   alert(msg);
   }



function updateDiv(result)
{
    if(( result == null) || (result == 'undefined'))
        return false;
    if(curTCID == null)
        return false;
    
    curDataDivShow = result;
    if(curDataDivShow.length<=0)
        return false;
    var strGobal="";
    for(iM=0; iM<(curDataDivShow.length-1);++iM)
    {   
        var _value=curDataDivShow[iM]; 
        if(_value)
        {
            var style = (_value[_value.length-1]).toString();
            var value=_value[0];
            var moreText=_value[1];
           
            var idstr = "itemid" + iM;
            var str = "<div  id=\""+idstr+"\" class='gcAUC' onclick='onItemClick(\""+idstr+"\",\""+curTCID+"\",\""+iM.toString()+"\"); ' >"
                  +"<div class='gcLAC' >"
                  +  "<div class='gcLAC1'>" + value + "</div>"
                  + "<div class='gcLACE'>" + moreText + "</div>"
                  +"</div>" 
                  +"</div><div style='clear:both;'></div>"; 
                  if (style == "1")
                  {
                    str = "<div  id=\""+idstr+"\" class='gcAUCC' onclick='onItemClick(\""+idstr+"\",\""+curTCID+"\",\""+iM.toString()+"\"); ' >"
                      +"<div class='gcLAC' >"
                      +  "<div class='gcLAC1'>" + value + "</div>"
                      + "<div class='gcLACE'>" + moreText + "</div>"
                      +"</div>" 
                      +"</div><div style='clear:both;'></div>"; 
                  }
                  strGobal+=str;  
                  
         }
    }
     var  divShow= $get(divShowCID);
     var _value=curDataDivShow[curDataDivShow.length-1]; 
     
     
     var strr = "<div class='gcAUCH'>"
                  +"<div class='gcLAC'>"
                  +  "<div class='gcLAC1'> Mã </div>"
                  + "<div class='gcLACE'> Tên </div>"
                  +"</div>" 
                  +"</div><div style='clear:both;'></div>";
       var strr2 = "<div class='gcDIVF'>Tổng số: ("+_value[0].toString()+" phần tử) "
                  +"</div>";
    
       var text = $get(curTCID);
       if(text)
       {
           
            if(text.offsetWidth>200)
            {
                strr = "<div  class='gcAUCH' "+ "style='width:"+(text.offsetWidth+19).toString()+"px !important;'>"
                      +"<div class='gcLAC'>"
                      +  "<div class='gcLAC1'> Mã </div>"
                      + "<div class='gcLACE'> Tên </div>"
                      +"</div>" 
                      +"</div><div style='clear:both;'></div>";
                strr2 = "<div style='width:"+(text.offsetWidth+19).toString()+"px !important;' class='gcDIVF'>Tổng số: ("+_value[0].toString()+" phần tử) "
                      +"</div>";
                divShow.innerHTML =  strr+ "<div style='width:"+(text.offsetWidth+19).toString()+"px !important;' class='gcDIVShow2'>"+strGobal+"</div>"+strr2 ;
            }
            else
                divShow.innerHTML =  strr+ "<div class='gcDIVShow2'>"+strGobal+"</div>"+strr2 ;
       } 
       
       divShow.style.width = text.offsetWidth+21;
       if((text.offsetWidth+21)< 150 )
            divShow.style.width = 150;
       if(curTCID.indexOf('NVXLId_Ten6') >=0)
       {
            divShow.style.width = 180;
       }
       divShow.style.display = "block";
       
       
       if(text)
       {
          var divBounds=Sys.UI.DomElement.getBounds(text);
          var position = new Sys.UI.Point(divBounds.x,divBounds.y+divBounds.height);
          
           var ver = getInternetExplorerVersion();    
          if (ver > -1) 
          {        if (ver >= 8.0)       
                     {
                        position.y +=34;    
                        position.x +=3;    
                     }
          }
          
          var div = $get(divShowCID);
         $common.setLocation(div,position);
       }
}





function FormatDiv(str, msg)
{
    var buildStr = "<div class='ErrorMsgServer'>"
        + "<div class='ErrorMsgServerCaption'>" + msg + " </div>"
        + str
        +"</div>";
    return buildStr;
}
/* ------------------------------------------------------------------- */

